package ModelLayer;
/**
 * 
 * @Author (Alexander Hvidberg, Dennis Kirkebak & Thomas Kulmbach)
 * @Team (Group 1)
 * @Version (08/11/13)
 * 
 */
public class Rental
{
    // instance variables 
    private int id;
    private String date;
    private int period;
    private boolean stillOnLoan;
    private DVD dvd;
    private Person person;
    private int articleNumber;

    /**
     * Constructor for objects of class Rental
     * 
     * @param int id - the id of the rental
     * @param String date - the date of the rental
     * @param int period - the period of the rental
     * @param Person p - the person of the rental
     * @param DVD d - the dvd of the rental
     */
    public Rental(int id, String date, int period, Person p, DVD d)
    {
        // initialise instance variable
        dvd = d;
        this.id = id;
        this.date = date;
        this.period = period;
        stillOnLoan = true;
        person = p;
        articleNumber = d.rentArticle();

    }
    
    /**
     * Unrents the article
     * 
     * @param int articleNumber - the serialnumber of the article
     */
    public void unrent(int articleNumber){
        dvd.unrentArticle(articleNumber);
    }
    
    /**
     * Update the information about this rental 
     * 
     * @param String date - the date of the rental
     * @param int period - the period of the rental
     * @param Person p - the person of the rental
     * @param DVD d - the dvd of the rental
     */
    public void updateRental(String date, int period, Person p, DVD d)
    {
        this.date = date;
        this.period = period;
        person = p;
        dvd = d;
    }
    
     /**
     * Print details about the rental.
     */
    public void printDetails()
    {
        
        System.out.println("\n ***Rental Info*** \n"
                          +"\nID: " + id
                          +"\nDate: " + date
                          +"\nPeriod: " + period
                          +"\nOn loan: " + stillOnLoan
                          +"\n\n ***Person Info***"
                          + person.printDetails()
                          +"\n ***DVD info*** \n");
                          dvd.printDVDInfo();
                          System.out.println(" \n");
                          System.out.println("\n Copy serial number: " + articleNumber);
        
    }      
    
    //Set og get metoder.
    /**
     * Set the ID of the rental
     * 
     * @param int id - the ID
     */
    public void setId(int id)
    {
        this.id = id;
    }
    
    /**
     * Set the date of the rental
     * 
     * @param String date - the date
     */
    public void setDate(String date)
    {
        this.date = date;
    }
    
    /**
     * Set the period of the rental
     * 
     * @param int period - the period
     */
    public void setPeriod(int period)
    {
        this.period = period;
    }
    
    /**
     * Set if stil on loan
     * 
     * @param boolean still - Still on loan
     */
    public void setStillOnLoan(boolean still)
    {
        stillOnLoan = still;
    }
    
    /**
     * Set the person of the rental
     * 
     * @param Person p - the person
     */
    public void setPerson(Person p)
    {
        person = p;
    }
    
    /**
     * Set the dvd of the rental
     * 
     * @param DVD d - the dvd
     */
    public void setDVD(DVD d)
    {
        dvd = d;
    }
    
    /**
     * Get the articlenumber
     * 
     * @return int articleNumber - the articlenumber
     */
    public int getArticleNumber(){
        return articleNumber;
    }
    
    /**
     * Get the rental id
     * 
     * @return int id - the id
     */
    public int getId()
    {
        return id;
    }
    
    /**
     * Get the date of the rental
     * 
     * @return String date - the date
     */
    public String getDate()
    {
        return date;
    }
    
    /**
     * Get the period of the rental
     * 
     * @return int period - the period
     */
    public int getPeriod()
    {
        return period;
    }
    
    /**
     * Get if on loan
     * 
     * @return boolean stillOnLoan - if on loan
     */
    public boolean getStillOnLoan()
    {
        return stillOnLoan;
    }
    
    /**
     * Get the person on the rental
     * 
     * @return Person p - the person
     */
    public Person getPerson()
    {
        return person;
    }
    
    /**
     * Get the dvd that is rented out
     * 
     * @return DVD d - the dvd
     */
    public DVD getDVD()
    {
        return dvd;
    }
    
     
}
